public class ThreadDemo4 {
    public static void main(String[] args) {
        Thread t = new Thread(){
            @Override
            public void run() {
                int count = 0 ;
                while(count < 3){
                    count++;
                    System.out.println("线程正在运行...");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("线程运行结束!");
            }
        };
        t.start();

        try {
            System.out.println("join 执行开始");
            t.join();//这里会发生线程阻塞
            System.out.println("join 执行结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
